package com.hspedu.properties_;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

/**
 * @author DL5O
 * @version 1.0
 */
public class Properties02 {
    public static void main(String[] args) throws IOException {
        //使用Properties 类来读取mysql.properties文件

        String filePath = "src\\mysql.properties";
        //1.创建Properties文件
        Properties properties = new Properties();
        //2.加载指定的配置文件
        properties.load(new FileReader(filePath));
        //3.把k-v显示控制台
        properties.list(System.out);
        //4.根据key 获取对应的值

        String ip = properties.getProperty("ip");
        String user = properties.getProperty("user");
        String pwd = properties.getProperty("pwd");
        System.out.println("ip地址为:" + ip);
        System.out.println("用户名为:" + user);
        System.out.println("密码为:" + pwd);
    }
}
